<template>
	<view id="SortContaint">
		<view class="time">{{time}}</view>
		<Gju></Gju>
		<view class="bott">
			<view class="left">
				<image src="../../static/logo.png" @click="open"></image>
			</view>
			<view class="min">
				
			</view>
			<view class="right">
				<!-- <button @click="open">打开弹窗</button> -->
				<image :src="img" @click="a == false ? play() : panse()" ></image>
			</view>
			<uni-popup ref="popup" :mask-click="false">
				<view class="box">
					<text class="title">新冠肺炎</text>
					<ul>
						<li>累计确诊个数:{{list.confirm}}</li>
						<li>疑似{{list.suspect}}</li>
						<li>累计治愈个数{{list.heal}}</li>
						<li>累计死亡个数{{list.dead}}</li>
						<li>现有{{list.confirm-list.heal-list.dead}}</li>
	<li>累计境外输入个数{{list.input}}</li>		
					</ul>
				</view>
				<button @click="close">关闭</button>
			</uni-popup>
			<video style="width: 1px;height: 1px;" :src="video"  autoplay="autoplay" id="myVideo"></video>
		</view>

	</view>
</template>

<script>
	import Gju from '../gju/index.vue'
	export default {
		components: {
			Gju,
		},
		data() {
			return {
				time: "",
				ip: "",
				video: "",
				img: '../../static/yinle.png',
				a: false,
				list:'',
				nickname:"",
				logo:""
			}
		},
		onLoad() {
uniCloud.callFunction({
  name: 'chb-check-update',
  data: {
    appid: plus.runtime.appid,
    version: plus.runtime.version
  },
  success(e) {
    if (e.result.isUpdate) {//需要更新
      // 提醒用户更新
      uni.showModal({
        title: '更新提示',
        content: e.result.note ? e.result.note : '是否选择更新',
        success: (ee) => {
          if (ee.confirm) {
            plus.runtime.openURL(e.result.url);
          }
        }
      })
    }
  }
})
		},
		mounted() {
			this.videoContext = uni.createVideoContext('myVideo');
			uni.request({
				url: 'https://api.uomg.com/api/rand.music?sort=热歌榜&format=json',
				success: (res) => {
					console.log(res.data.data.url)
					if (res != undefined) {
						this.video = res.data.data.url

					}
					this.img = "../../static/70BasicIcons-all-65.png"
				},
				fail() {
					console.log(1111)
				}
			});










			getDate();
			setInterval(getDate, 1000);
			var bb = this

			function getDate() {
				var date = new Date();
				var year = date.getFullYear();
				var month = date.getMonth() + 1;
				month = month < 10 ? '0' + month : month;
				var dates = date.getDate();
				dates = dates < 10 ? '0' + dates : dates;
				var arr = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
				var day = date.getDay();
				var hour = date.getHours();
				var half = hour >= 12 ? '下午' : '上午';
				hour = hour <= 12 ? hour : (hour - 12);
				hour = hour < 10 ? '0' + hour : hour;
				var min = date.getMinutes();
				min = min < 10 ? '0' + min : min;
				var sed = date.getSeconds();
				sed = sed < 10 ? '0' + sed : sed;
				// if(bb.time!=undefined){

				// }

				if (bb != undefined) {
					bb.time = year + '年' + month + '月' + dates + '日 ' + arr[day] + ' ' + half + hour + '点' + min + '分' +
						sed + '秒';
				}
			}
uni.request({
	url:"https://api.66mz8.com/api/ip.info.php",
	success(res) {
		console.log(res.data.region)
		uni.setNavigationBarTitle({
			title: '欢迎来自' + res.data.region + "的靓仔"
		});

	}
})
			// axios.get(`https://api.66mz8.com/api/ip.info.php`).then(res => {
			// 	console.log(res.data.region)
			// 	localStorage.setItem('ip', res.data.region)
			// 	// uni.setNavigationBarTitle({
			// 	// 	title: '欢迎来自' + res.data.region + "的靓仔"
			// 	// });
			
		 const value = uni.getStorageSync('storage_key');
		    if (value==true) {
		        console.log(value);	
		    }
			setTimeout(()=>{
				 uni.setStorageSync('storage_key', "false");
			},20000)
	
			// })
		},
		methods: {
			play() {
				if(this.video){
					this.a = true;
				    this.img = "../../static/70BasicIcons-all-64.png";
					this.videoContext.pause();
				}
					
				},
				panse() {
					this.a = false;
					this.img = "../../static/70BasicIcons-all-65.png"
					this.videoContext.play(); 
				},
		


		open() {
		uni.request({
			url: 'https://c.m.163.com/ug/api/wuhan/app/data/list-total',
			success: (res) => { 
			
				let data=res.data.data.chinaTotal
				if (res != undefined) {
					this.list={
					"confirm":data.total.confirm,
					"suspect": data.total.suspect,
					"heal": data.total.heal,
					"dead": data.total.dead,
				"severe": data.total.severe,
			"input": data.total.input	,
			"timestamp":data.total.timestamp
					}
					this.tady={
						"confirm":data.today.confirm,
								"suspect": data.today.suspect,
								"heal": data.today.heal,
								"dead": data.today.dead,
							"severe": data.today.severe,
						"input": data.today.input	,
					
						"storeConfirm":data.today.storeConfirm
					}
				}
				
			},
			fail() {
				console.log(1111)
			}
		});
		
			this.$refs.popup.open('top')
		},
		close() {
			this.$refs.popup.close()
		}
	}
	}
</script>

<style>
	#SortContaint {
		width: 750rpx;
		height: 100vh;
		background: white;
		padding-left: 40rpx;
		padding-right: 40rpx;
		padding-bottom: 32rpx;
		box-sizing: border-box;
		background: #599BDC;
		position: relative;
	}



	.time {
		height: 126rpx;
		width: 750rpx;
		line-height: 126rpx;
		font-size: 32rpx;
		font-weight: 800;
		color: #F0F0F0;
		/* text-align: center; */
	}
	.bott {
		/* height: 64px; */
		/* background: #4CD964; */
		position: relative;
		bottom: 0;
	}

	.left {
		width: 100rpx;
		height: 100rpx;
		position: absolute;
		left: 0;
		/* background: #0000FF; */
	}

	.min {
		position: absolute;
		left: 126rpx;
		right: 126rpx;
		height: 100rpx;
		background: red;

	}

	.right {
		width: 100rpx;
		height: 100rpx;
		position: absolute;
		right: 0;
		/* background: #0000FF; */
	}

	.box {
		width: 646rpx;
		height: 790rpx;
		background: #B33630;
	}

	image {
		width: 100rpx;
		height: 100rpx;
		border-radius: 40%;
		z-index: 999;
	}
	.title{
		position: absolute;
		left: 50%;
		font-size:60rpx;
		margin-left: -124rpx;
	}
	.box{
		position: relative;
	}
	ul{
		position: absolute;
		top: 132rpx;
		background: #000000;
		
	}
	li{
		list-style: none;
		float: left;
		margin-left: 134rpx;
		height: 100rpx;
		color: #F0F0F0;
	}
</style>
